/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-11-17
 * Time: 10:51
 */
public class Hash {
    //直接定制法(字符串中第一个只出现一次的字符)
    public static int firstUniqChar(String s) {
        int[] arr = new int[26];
        for (int i = 0; i < s.length(); i++){
            char a = s.charAt(i);
            arr[a - 'a']++;
        }
        for (int i = 0; i < s.length(); i++){
            char a = s.charAt(i);
            if (arr[a - 'a'] == 1) return i;
        }
        return -1;
    }
    public static void main(String[] args) {

    }
}
